// BusinessPage.cs
// Facebook/Framework/Service
// Copyright (c) 2007, Nikhil Kothari. All Rights Reserved.
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using Facebook.Service.Core;

namespace Facebook.Service {

    /// <summary>
    /// The local business information associated with a PresencePage.
    /// </summary>
    public class BusinessPage : FacebookEntity {

        // TODO: Hours

        private bool _parkingTransformed;

        internal BusinessPage(Hashtable pageState)
            : base(pageState) {
        }

        /// <summary>
        /// The set of parking options available.
        /// </summary>
        public string Parking {
            get {
                if (_parkingTransformed == false) {
                    return TransformParking();
                }
                return GetState<string>("parking");
            }
        }

        /// <summary>
        /// The public transportation or directions information.
        /// </summary>
        public string Transit {
            get {
                return GetState<string>("public_transit") ?? String.Empty;
            }
        }

        private string TransformParking() {
            Debug.Assert(_parkingTransformed == false);

            object o = this["parking"];
            string parking = FacebookResponse.CoerceOptions(o);

            this["parking"] = parking;
            _parkingTransformed = true;

            return parking;
        }
    }
}
